// 引入组件所需方法
import { createRouter, createWebHistory, createWebHashHistory } from "vue-router";

// 创建路由对象
// 2. 创建路由对象
const router = createRouter({
  // 以下代码生成的是hash模式
  // history: createWebHashHistory(),

  // 以下的设置是history模式
  history: createWebHistory(),
  routes: [
    {
      path: '/',
      redirect: '/home'
    },
    {
      name: 'home',
      path: '/home',
      component: () => import('../components/Home.vue')
    },
    {
      name: 'about',
      path: '/about',
      component: () => import('../components/About.vue')
    },
    {
      name: 'news',
      path: '/news',
      component: () => import('../components/News.vue')
    },
    {
      name: 'demo',
      path: '/demo',
      component: () => import('../components/Demo.vue')
    }
  ]
})

//3. 书写路由规则

export default router
